package cloud.shyidong.main.controller;

import cloud.shyidong.main.feign.SystemFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.Map;

@RestController
public class UserController {

    private SystemFeign systemFeign;

    @Autowired
    public void setSystemFeign(SystemFeign systemFeign) {
        this.systemFeign = systemFeign;
    }

    @GetMapping("/user/list")
    public Map<String, Object> userList() {
        Map<String, Object> result = new LinkedHashMap<>();
        Map<String, Object> userMap = systemFeign.userList();
        if ("0".equals(userMap.get("code").toString())) {
            result.put("code", 0);
            result.put("data", userMap.get("data"));
        } else {
            result.put("code", 1);
        }
        return result;
    }

}
